There in no provision in the UN Charter for withdrawal. Although there is a provision for expulsion (see Chapter 2 Article 6), if the security council says so. This was a deliberate omission because as Nations Encyclopedia says:
The majority feeling at the San Francisco Conference was that provisions for withdrawal would be contrary to the principle of universality and might provide a loophole for members seeking to evade their obligations under the Charter.
Basically in 1933, Japan walked straight out of the League of Nations after the League accepted the Lytton Report, and the people setting up the United Nations didn't want people to be able to use withdrawal as a form of blackmail to force the UN to do something or to shirk their obligations.
There is however a case of (relatively) large nation trying to leave the UN. In 1965 during a conflict between Malaysia and Indonesia. President Sukarno of Indonesia threatened to leave the UN if they let Malaysia join the Security Council. Which they did:
On 20 January 1965 First Deputy Prime Minister and concurrently Minister of Foreign Affairs Subandrio addressed a letter to the Secretary General explaining further the reasons for Indonesian withdrawal from the United Nations by stating among others that Malaysia was rejected by two of three signatories to the Manila Agreement and was merely a tool of the British neo-colonialism and pushed by manipulations and pressures of colonial powers to occupy a seat in the Security Council and questioned Malaysia’s ability to contribute towards the maintenance of peace and security in the world. He assured that Indonesia still upholds the lofty principle of international co-operation enshrined in the U.N. Charter while not being a member of the United Nations itself. He further stated that Indonesia decided at this stage and under the present circumstances to withdraw from the United Nations and also from the specialized agencies such as FAO, UNICEF and UNESCO. He informed that due to technical reasons the Indonesian Permanent Mission would only be closed on 1 March 1965.
However after a coup by General Suharto, the de facto new government of Indonesia sent a telegram in September 28 1966 informing them that
will resume full co-operation with the United Nations and to resume participation in it's activities
Although no other country has tried leaving the UN, their have been many proposals surrounding a US withdrawal, none of these proposals have gained widespread support however and no bill has such been passed.
To withdraw your countrys' sovereign government or national parliament would have to pass some law announcing a unilateral withdrawal of the UN
And yes theoretically a country could continue to function outside of the UN, and could continue to trade under World Trade Organisation rules. However they risk turning into a bit of an international pariah state, and they will greatly lose influence and relations on the world stage. It all depends on the circumstance of their withdrawal, and the UN could impose sanctions if they felt the need to.
It is worth mentioning that Palestine is not de facto a sovereign state (it has been occupied by Israel), and thus doesn't have the power to join the UN in the first place