Complex sentence: Gibraltar's inhospitable terrain made it an unpopular place to live and it convicts from the kingdom of Granada had to be offered the possibility of serving their sentence in the Gibraltar garrison as an alternative to prison.
Split into simpler sentences: Gibraltar's inhospitable terrain made it an unpopular place to live. To boost the population, convicts from the kingdom of Granada were offered the possibility of serving their sentence in the Gibraltar garrison as an alternative to prison.