I understand that one of the major issues between Israel and Palestine are Israeli settlements in Palestinian land. Israel keeps building these settlements, despite what I understand to be the international consensus that doing so is illegal. I would also expect that this puts the settlers in greater danger (though I can't speak to that statistically). So why does Israel continue to do it? What does it stand to gain?
This requires a bit of a history lesson. In 1949, after the first Arab-Israeli war, Israel gained its independence. Israel negotiated with its neighbors the 1949 Armistice Agreements. These agreements established the 1949 Armistice Lines (often referred to as the 1967 borders, for reasons that will shortly become apparent) as de facto borders.
However, these lines were never intended to be final borders. Every Arab country bordering Israel except Lebanon (meaning Syria, Egypt, and Jordan) had clauses in the armistice agreements specifying that the armistices lines were temporary, and were not meant to define final borders. The most relevant agreement here is Israel's agreement with Jordan. The Jordanian agreement specified that the borders existed only out of military necessity and could be changed. From the agreement with Jordan:
no provision of this Agreement shall in any way prejudice the rights, claims and positions of either Party hereto in the ultimate peaceful settlement of the Palestine question, the provisions of this Agreement being dictated exclusively by military considerations.
In June of 1967, Egypt blockaded the Strait of Tiran, which Israel stated it would consider an act of war. Israel responded by destroying the Egyptian airforce. Faced with an Egyptian, Syrian, and Jordanian invasion, Israel defeated the three Arab armies in six days.
Israel captured the Sinai and the Gaza Strip from Egypt. Israel would give the Sinai back to Egypt in the 1979 Camp David Accords, and unilaterally withdrew from the Gaza strip according to the 2005 Unilateral Disengagement Plan.
Israel captured the Golan Heights from Syria, and annexed the Golan Heights in 1981 via the Golan Heights Law. Though the armistice agreement with Syria stressed the mutability of the armistice lines, and though Syria refused Israel's offer, to return the Golan Heights in exchange for peace, that annexation is not internationally recognized.
Finally, we come to the West Bank. The West Bank was captured from Jordan, though only East Jerusalem has been annexed by Israel. Since the 2005 disengagement from Gaza, Israeli settlements are within the West Bank. At first, settlements were established by Israeli citizens, but with implicit government approval (Source: The Accidental Empire by Gershom Gorenberg).
Many of these settlements were established on land you'd be hard pressed to call Palestinian. The Palestinians never held sovereignty over the West Bank, and rejected all promises of sovereignty over those areas (including in 1936-1937, 1938, and 1947), and some of the areas on which settlements were established, like Gush Etzion and Hevron, had Jewish communities that had existed sometimes for thousands of years before they were depopulated in Arab riots and by Arab armies in Israel's war for independence.
You are correct that the international community considers the settlements illegal, but just to clear up confusion, that's not because the settlements were established on land belonging to another party. Rather, the settlements are considered illegal because they are considered to violate the Geneva Convention's prohibition on population transfer. The Geneva Convention prohibits a state from transferring its population into occupied territory (though it should be noted that settlers moving to occupied territory were not coerced). Though the international consensus is that the settlements are illegal, there is still legal dispute about this issue. As Julius Stone, former Professor of International Law at the University of Sydney points out:
We would have to say that the effect of Article 49(6) is to impose an obligation on the State of Israel to ensure (by force if necessary) that these areas, despite their millennial association with Jewish life, shall be forever judenrein. Irony would thus be pushed to the absurdity of claiming that Article 49(6), designed to prevent repetition of Nazi-type genocidal policies of rendering Nazi metropolitan territories judenrein, has now come to mean that ... the West Bank .. must be made judenrein
Finally, we can consider why Israel continues to promote settlement growth. Though there may be specific political reasons for specific settlement projects, the overarching reason Israel promotes settlement growth is security. Under the armistices lines, Israel was cut off by the West Bank, and enemy borders were close to population centers. For example, the distance between the West Bank city of Qalqilya and the Mediterranean sea is only about 9 miles.
If you look at Israel's justifications for its settlements, from Ariel to the E1 Plan, they largely involve establishing a foothold on land it can use to protect itself (though one of the largest Israel settlements, Ma'ale Adumim, is also intended to provide cheap housing to people who can't afford to live in Jerusalem). Former International Court of Justice justice and State Department Legal Advisor Stephen Schwebel defended the settlements as justified by military necessity, saying:
(a) a state [Israel] acting in lawful exercise of its right of self-defense may seize and occupy foreign territory as long as such seizure and occupation are necessary to its self-defense;
(b) as a condition of its withdrawal from such territory, that State may require the institution of security measures reasonably designed to ensure that that territory shall not again be used to mount a threat or use of force against it of such a nature as to justify exercise of self-defense;
It is commonly claimed that the establishment of Israeli settlements constitutes a land grab, however this claim does not stand up to scrutiny. The settlement blocs Israel wishes to keep in an agreement with Palestine comprise only a few percent of the West Bank, and Israel is willing to transfer an equal amount of land in exchange for those settlements.
In 2008, Israeli Prime Minister Ehud Olmert made an offer to the Palestinians in which Israel would retain some settlement blocs and transfer an equal amount of land from behind the armistice lines to Palestine. Here is an approximate map (I say approximate because no official maps were produced). Given that Israel is willing to transfer to Palestine as much land as it wishes to keep, the settlements cannot sensibly be framed as a land grab: they grant Israel no additional land.
In terms of danger: the settlements experienced a good deal of violence during the Second Intifada: hundreds of Israeli civilians died. However, since Israel installed a wall surrounding most of the settlement population, terrorist incidents have been substantially reduced, meaning that security is less of an issue for settlers now.
I recognize this may be somewhat more of an answer than you were looking for, and it does cover more than you may have expected, but hopefully it gives you a better idea of the context of the settlements and why Israel pursues them. I suppose the TL;DR version of this is that Israel is promoting settlements on land that isn't Palestinian for security reasons.
The short answer is because the Bible/Torah states that God promised them the land. Therefore letting the Palestinians have it would go against the will of God.
The rest of the world calls the area West Bank, but in Israel it is called Judea and Samaria because that is the names it had when the Israelite kingdoms ruled about 2300 years ago. These names were choosen because it implies a Jewish claim to the land.
The long answer is that Nationalism is an incredibly strong force!
Most states that are nations (I'll explain the difference in a moment) have a "founding myth", identity, slogan or rationale justifying its existence. It is stuff that answers questions like "Who we are?", "Where do we come from?" and so on. It is not negative at all that countries have founding myths.
For example, United States' slogan is "the land of the free" because freedom is a core concept of the US founding myth. It is expressed in the constitution but also in various poems "Give me your tired, your poor, Your huddled masses yearning to breathe free..."
Syria, on the other hand, has no strong founding myth. It's a state that was formed by the colonial powers carving up a piece of land and handing it over to an Arab despot. This is why Syria in a sense is a state but not a nation.
I suspect a lot of states which are volatile (such as Syria) are so because they don't have a Nationalistic founding myth which glues their populations together.
Israel's Founding Myth
Back to Israel. It's founding myth is: a Jewish homeland in the land the Israelites previously inhabited.
3000 years ago under King Saul when the kingdom was at its greatest extent it looked like this map:
Note that this map includes a big chunk of land east of the Jordan river. Indeed, some of the extremist early Zionists wanted to claim that land too, but the political situation made it impossible and the claim disappeared from the founding myth. (The Rise of the Israeli Right, p. 138, Schindler).
A large chunk of Israel's Jewish population isn't religious, but they still subscribe to the basic idea of the nation. That they are the same people as the ancient Israelites and that they therefore have the right to return to the land they once lived in.
I'm skipping over a lot of stuff here because my answer is getting to long. A lot of the early Zionists were Communists and Socialists and they wanted a Democratic state just as much as they wanted a Jewish one. Israel still has those strains in it and overall is much more left-leaning than the US for example.
That left-wingers has acted as a counter-balance to the right-wingers who would prefer to drive all Palestinians out. These two forces met in the middle and resulted in a compromise consisting of the settlement program.
Most settlers are of course are neither left nor right wing. They are just ordinary people with no strong political opinions and they sincerly Just. Want. Peace. But they are being used by the government trying to Judaize the West Bank. Much like China moves Han Chinese into Tibet, the Soviet Union moved Russians into Estonia and Morocco moved Moroccans into Western Sahara.
The idea is that people won't support decisions that negatively affect them. Israel deciding to relinquish the West Bank would negatively affect the settlers as they would have to leave their homes. Therefore, the more settlers there are on the West Bank, the harder it becomes for future cabinets to remove them.
This policy is known as "creating facts on the ground". Eventually, the original Israeli justification for keeping the West Bank, "God gave us this land", will fade away and be replaced with "We have been here for a long while" which is much more palatable to the rest of the world.
It is very similar to the concept of Manifest Destiny which were a widespread belief among Americans in the 19th century that the US should expand from coast to coast. Even that it was God's will that they should. It helped them justify the Indian Removal Act and various other not so very nice things that were done against the natives.
From a rational perspective, the settlements are a huge drain on the Israeli economy. Military spending / capita is 5.4% which is more than what the US spends. The security benefit is non-existent as anything gained from them is lost many times over by having part of the population living in hostile territory. If Israel was a corporation, the settlements would have been abandoned long ago, purely as a cost-cutting measure.
But Nationalism isn't rational so most Israelis prefer that the settlements are kept even if the costs outweights the benefits.
Because Israel controls those territories, they gain new housing for their growing population.
"Palestinian land" has been controlled by many different countries for a very long time.
The region has been controlled by numerous different peoples, including Ancient Egyptians, Canaanites, Israelites, Assyrians, Babylonians, Persians, Ancient Greeks, Romans, Byzantines, the Sunni Arab Caliphates, the Shia Fatimid Caliphate, Crusaders, Ayyubids, Mameluks, Ottomans, the British and modern Israelis and Palestinians.
The Six Day War resulted in Israel controlling territory and the countries they were in conflict with giving up all rights to.
By June 10, Israel had completed its final offensive in the Golan Heights, and a ceasefire was signed the day after. Israel had seized the Gaza Strip, the Sinai Peninsula, the West Bank of the Jordan River (including East Jerusalem), and the Golan Heights.
The June 19 Israeli cabinet decision did not include the Gaza Strip, and left open the possibility of Israel permanently acquiring parts of the West Bank. On June 25–27, Israel incorporated East Jerusalem together with areas of the West Bank to the north and south into Jerusalem's new municipal boundaries.
Expanding the settlements is a very effective way to "stir up a hornet's nest". Every now and then some external party decides to try to help Israel and Palestine to achieve peace. Then the hawks in Israel push for more settlements and this heats up the conflict and the threat of a peace deal is avoided.
The original impulse came from Zionism, which is usefully understood as Jewish nationalism, despite the fact that, unlike the other peoples of Europe, they had no nation or state to speak of. This was the point of Jewish nationalism, to found a state where there was none before. This came at the tail-end of European colonialism which had pretty much colonised the globe apart from outposts such as the Ottoman Empire and China, but where Europe was intending mop up eventually. Thus, it can be seen as a European colony, despite they sanction themselves by pointing to ancient Biblical precedent - 2500 years ago! When Israel calls itself a democracy, it's generally as a euphemism for this strategy. One historical fact that butresses this analysis is that before they settled on Palestine as the location for their colony, they were were offered land in what is now Uganda.
The British Colonial Secretary at the time, Joseph Chamberlain, who was aware of the ambitions of the Zionist Organization, later named the World Zionist Organisation, and which had been founded by Theodor Herzl, an Austro-Hungarian journalist, and then later led by Chaim Weizmann, the first President of Israel, noted that
"If Dr Herzl were at all inclined to transfer his efforts to East Africa there would be no difficulty in finding land suitable for Jewish settlers."
He was prepared to offer them 13,000 square kilometres. However, when eventually it was understood that the British Empire, noting the weakness of the Ottoman Empire and was preparing to go to war with them for control of the Middle East, the Balfour Declaration was issued in 1917 after a committee had been established in April 1915, six months after hostilities had begun, to consider the future of Palestine. This had included representations from the Zionist leadership (as well as anti-Zionists) but there were no representations from the population that would be immediately and directly affected - the Palestinians themselves. This was a piece with colonial strategy, the natives, that is the indigenous population, interests were hardly considered, except as a kind of moral fig-leaf, which the Balfour Declaration itself paid lip-service to where it said:
It being clearly understood that nothing shall be done that may prejudice the religious and civil rights of existing non-Jewish communities in Palestine.
(It's interesting that they say 'non-Jewish' as opposed to 'Palestinians' as though a people ought to be defined by that which they are not). It should be understood that at the beginning of the twentieth century that Zionism was thought of as a fringe movement. It had barely made any real inroads into the Jewish communities world-wide. All this changed with the eventual victories of the Allied forces and the division of the spoils amongst them, including Palestine. And then, by the protection of powerful patrons, the British Empire, prominently at first, and then the American Empire (though it rather not use such an old-fashioned term - it disturbs their sense of democratic decorum).
Zionism then began to exhort the Jewish communities to Palestine, to not much success, at first. Palestine was far away, in an alien location, and not very European. All this changed with the holocaust when the Jewish communities fleeing that particular horror found they weren't made welcome in the USA by either their brethren, who had already settled there, or by the US state which closed the doors to Jewish immigration by legislation. This worked towards the benefit of Zionism but to the detriment of Palestinians.
Whereas the Balfour Declaration originally declared that it would establish a 'homeland' in Palestine for the Jewish community, the Zionist leadership determined that they would establish a state. This meant the expulsion of the Palestinians, in an act of ethnic cleansing that the Palestinians call the Nakba, and which the Israel is generally silent on, as it must, due to its national mythology on the founding of Israel. And is a piece of Golda Meirs (the fourth Prime-minister of Israel) declaration:
There were no such thing as Palestinians. When was there an independent Palestinian people with a Palestinian state? It was either southern Syria before the First World War, and then it was a Palestine including Jordan. It was not as though there was a Palestinian people in Palestine considering itself as a Palestinian people and we came and threw them out and took their country away from them. They did not exist.
Which is a strange piece of diplomatic-speak, confusing both ideas of identity, nation and the 'civil rights' of a people, whether they are constituted as a polity or not, to hold onto land and territory that is theirs by right of having lived there for many generations.
Thus by regarding the Palestinians as 'unpeople', as people not deserving the full status of 'a people', Israel stands to gain a great deal: by a process of attrition, it stands to gain the rest of Palestine. They are prepared to wait and their actions suggest that by the application of steady pressure they will eventually turn over all of Palestine into Eretz Israel (Greater Israel). This is all with the backing of their political patron - the USA - which pretends to be an impartial backer in this long running conflict but which uses Israel to secure its strategic interests in the Middle East.