Today most banking is private. Has there been any period in history where banking was (in part) state-owned and why was it privatized?
Yes. An important and currently highly relevant example is India.
In 1969, the Government of India issued the Banking Companies (Acquisition and Transfer of Undertakings) Ordinance, 1969 which nationalised the 14 largest private-sector banks of India, which contained about 85% of the bank deposits in the country. In 1980, 6 more banks were nationalised. After that, several mergers have taken place among these state-owned banks (see this for reference). See this for a list of public sector banks of different kinds in India.
Several reasons were listed for this move: expanding the reach of banking to regions where the private sector would not want to go, removing regional imbalance; prioritising certain sectors deemed crucial for the country's economic growth and the welfare of the people; controlling private monopolies etc. Before the move, the then Prime Minister of India, Mrs. Indira Gandhi had released the paper, "Stray thoughts on Bank Nationalisation", expressing her views (see this and this). Financial inclusion of the poor was seen as an important goal, as they were (and to an extent still are) un-banked/ under-banked and have to pay extraordinarily high interest to traditional moneylenders. Abhijeet Banerjee and Esther Duflo provide a nice description of the poor in India borrowing in their book, Poor Economics.
In 2015, public banks had 74.28% of the market share in loans in India, which reduced to 59.8% in 2020 (see here). Thus, the public sector banks still largely dominate the banking sector in India.
But over time, several issues with public sector banks have come to surface: they face losses in rural India (which is perhaps the reason private banks didn't go to those places, which prompted Mrs. Gandhi to nationalise), large over-dues due to lending to certain sectors and demographics, worrying shares of non-performing assets etc. (see here). Furthermore, there is a lack of competition and exposure to large corporates more than the private banks have. This is not to say that private banks aren't facing problems: large private banks like ICICI, Yes Bank and HDFC have seen problems very recently.
In the last few years, the Indian government has expressed its desire to privatise many of the banks, due to the stated problems. The government intends to introduce the Banking Laws (Amendment) Bill, 2021 in the ongoing winter session of the parliament (see here). As I write this answer, 900,000 employees of public-sector banks are on strike nationwide (for 16 and 17 December, 2021), opposing the move to privatise banks (see here and here). Among many other reasons, they fear that privatisation will lead to a loss of banking jobs, as private entities would try to cut costs (see here).
The government has not yet introduced the bill, but is expected to do it soon in the ongoing session of the parliament.
In France a number of banks were nationalized after the 1939-1945 war. by the law of December 2, 1945. In short, that law first nationalized the Banque de France and gave it the monopolistic privilege of emission of money, and then nationalized a number of major banks:
- Banque Nationale du Commerce et de l'Industrie and Comptoir National d'Escompte de Paris which later became the Banque Nationale de Paris
- Credit Lyonnais
- Société Générale
The rationale behind those nationalizations was that the National Council of Resistance (Conseil National de la Resistance) (among its members was the French Communist Party...) wanted to be able to control the financing the economic recovery.
Later, when François Mitterand was elected in 1981, a number of other banks are again nationalized (ref). Here again the rationale was that the left parties (French Communist Party and French Socialist Party) did not trust private banks to support their politics.
When the right parties winned the elections in 1986, some banks are privatized back: Paribas, CCF, Société Générale (ref). Here the rationale is just that economy should not be part of the sovereign domain, and that the government was in need of fresh money. The last major banks will be privatized later: BNP 1993 and Credit Lyonnais 1999.
All this only shows that the left parties (communist and socialist parties) do not trust private capitals to support their politics, while the right parties (RPR, UMP, LR) prefers banks to be given to private economics.
I could not find any evidence that either way was better for the national economy. The only values I could find is that the whole nationalization of 1982 costed around 50 billion francs and that when they were later privatized backs the government received more (between 65 and 100 billion francs depending on sources), so being nationalized were not that bad for those companies... (ref) - it should be noted that this values contains more than banks.
Yes in USSR all banks, like everything else was state owned. Although there is no much literature on it as the system was opaque. You can have look at Kuschpèta (1978) for some exploration.
why was it privatized?
Because Soviet Union collapsed. Also retail banking is private service there is not much if any economic rationale for government ownership ideology aside.
Some sort of government involvement is the norm. In the US, the FDIC and Federal Reserve Bank are central parts of the banking industry, and while they are in some sense "independent", they aren't really private entities. Even private banks are highly regulated, with the government setting things such as reserve requirements, interchange limits, etc.
In the UK in 2008, the government took majority stakes in Royal Bank of Scotland and Lloyds Banking Group (two of the country’s four largest retail banks) to prevent their bankruptcy and the consequent collapse of the UK’s (and perhaps the world’s) financial system. It has since divested itself of Lloyds, but is still the majority owner of RBS.
In Portugal Caixa Geral de Depósitos, is state owned bank.
In Argentina, besides many private banks, there is a federally owned bank (Banco de la Nación Argentina, the largest in the country) and several provincially owned banks (among them, Banco de la Provincia de Buenos Aires, Banco de la Provincia de Córdoba, Banco Provincia Neuquén, Banco de la Ciudad de Buenos Aires; this last one is technically municipal).