It seems weird to me that Britain would let go of Palestine, knowing that it would erupt into war, without trying to come up with a compromise between the two parties...
There were numerous compromises proposed to work with the fact that both Israel and Palestine wanted and were promised the land. The 1947 UN plan, for instance, proposed a two state solution in Palestine, with the creation of a Jewish state and Arab state. This two-state solution would have still held the two states as closely linked with an economic union and mutual protection of minority rights. It was agreed to by most Jewish settlers, but rejected by Arabs under the basis that it violated the principles of self-determination laid out in the UDHR.
The reason the partition is so thorough now, though, is because of the series of wars fought between Israel and Arab states, the first of which established a much more stringent partition as well as less land for Palestine. This land shrank over the course of more wars, with the Intifadas creating even greater barriers.
It has to be understood, though, that Britain didn't necessarily know that the creation of Israel would lead to war. While there had been numerous riots and revolts throughout the early 20th century centring around both Arab nationalism and anti-Jewish sentiments, there was a certain degree of hope that the UN compromise would be accepted.
Why? Because all else had failed.
Since 1919, the British had been attempting to allow for some kind of compromise between the parties. The first attempt, the Faysal-Weizmann agreement, was essentially violated by both parties before the ink was dry: Faysal didn't follow through on the Arab portion, Weizmann didn't follow through on the Jewish one. In 1922, when Churchill's White Paper said that the Jewish homeland, not state, would be established in Palestine (not throughout Palestine), there was a big uproar in the Jewish community, which pledged to keep fighting for a state. The British were reluctant to give up control, though. And they wanted to create a Jewish state, since they figured it would be better for their interests.
Still, they kept trying to postpone a solution to the problem. Eventually, with the start of the Arab Revolt in 1936, they did something pretty big.
without trying to come up with a compromise between the two parties...
This was attempted. In 1937, they suggested a partition. This was called the Peel Commission Plan, and it proposed giving a larger portion to the Arab population, confining the Jewish state to the northern areas of the Galilee and coastline. However, the plan didn't just create a smaller Jewish than Arab state, it also called for up to 225,000 Arabs to "voluntarily" exchange populations, though only a few thousand Jews would have to move.
Needless to say, both sides rejected partition, and in 1938 the Woodhead Commission ruled out partition as a possible solution to the problem. Still, they kept trying. Further commissions were set up, and failed every time. In 1939, the White Paper released said that a state would be established in 10 years if there were peace and it seemed favorable, according to the will of the population. The White Paper also restricted Jewish immigration and land purchases, and made immigration (after a limit of 75,000 for the next 5 years) contingent on further Arab agreement to allow more immigration. Still, neither side initially accepted it, and only a few "representatives" (in quotes because it's uncertain to say they even represented the Arab side) agreed to the White Paper, while the Jews continued to reject it.
After riots in 1920, 1921, and 1929 (and intermittent violence and trouble in between), the Arab Revolt from 1936-1939, and WWII, the British were tired. They had spent mountains of money trying to hold the area and keep it peaceful. Both sides were fighting increasingly, and also fighting with the British (Jewish groups became more willing to fight the British at the end of WWII), and the assassination of Lord Moyne in 1944 by the radical Jewish group Lehi didn't help. They were tired. It would take tens of thousands, if not a hundred thousand or more, troops to quell the violence there. And the British had just gotten out of WWII. They had no more willpower to try more solutions, so they shoved it at the UN, announced they were going to withdraw, and decided enough was enough: they didn't want to have to deal with it anymore.
So it's not that they didn't try, because they did. They didn't try very well, if you ask most, but they tried. They just failed, and gave up, and the UN took over the plan with UNSCOP (UN Special Committee on Palestine). They created the 1947 partition plan, which also got rejected by the Arabs (but accepted by the Jews, and passed by the UN General Assembly), and the British were sticking to their timetable to withdraw no matter what. As soon as the 1947 plan passed, with the rejection by Arabs and acceptance by Jews, the boiling pot simmered over and a civil war began in earnest. No one was willing to break it up: again, would've taken too many troops and too much money, and the world watched as the British kept everyone else from intervening. Then when the British Mandate ended, Israel declared itself a state, and that was the end of that: I think you know what followed.
If you want a more detailed look at the history, you can check out some of my previous answers, such as this one.
It seems weird to me that Britain would let go of Palestine, knowing that it would erupt into war, without trying to come up with a compromise between the two parties
You have to consider what else was going on in the British Empire at the same time. While Palestine stands out today as one of the most important conflicts of our time, Palestine in 1948 was just one of many crises facing the postwar British Empire; Indian Independence and Partition, the Malayan Emergency, the Republic of Ireland Act of 1948, the beginning of the end for the British Dominions, the massive political reversal in Parliament that led the decolonization and welfare state campaign, the demilitarization following the war, the growing threat of communist domination of Europe, bankruptcy and insolvency, the reclaiming of lost colonies like Singapore and Hong Kong, and so many other issues. One problem that seemed to have a simple solution was the Palestinian issue; exit and give stewardship to the newly created UN to establish. The British passed the conflict along to a "higher entity" that they hope could resolve the issue in their stead.