South Korean President Chun Doo Hwan arrives here for a three-day official visit this week, the first by a Korean head of state since Japan concluded a stern colonial rule in Korea 39 years ago.

What would normally be a tiresome round of black-tie ceremonies has acquired major psychological importance in both countries, where memories of the long colonial era remain vivid.

Chun has said his visit will "lay a cornerstone for eternal good neighborly relations" with Japan, which like South Korea has close commercial and military ties with the United States. Japanese officials are making similar lofty predictions.

Diplomatic and commercial ties between the two countries, separated by only 120 miles of water, have strengthened in recent years. But there remains an undercurrent of distrust caused both by colonial memories and present-day inequalities of wealth and status.

Japan assumed total control of Korea in 1910. For the next 35 years, Koreans were Japanese subjects, forced to take Japanese names and bow to the Japanese emperor. Hundreds of thousands of Koreans were brought to Japan as forced laborers.

After independence, 20 years passed before the wounds had healed sufficiently to allow South Korea and Japan to establish diplomatic relations. It took another 20 years before a state visit such as Chun's became possible.

The visit, however, will not be risk-free for either side. Chun must contend with opposition groups at home that charge the Japanese have replaced colonial with economic control through investment and trade. They have already staged demonstrations against the visit in Seoul, the South Korean capital.

Japanese Prime Minister Yasuhiro Nakasone, meanwhile, while enjoying support for the visit from the political center, faces criticism both from the right and left. The left condemns Chun's government as a military dictatorship. The right sees no reason to entertain a man representing a people some Japanese still view as rude and backward.

About 700,000 Korean nationals, many of them sympathetic to Communist North Korea, live in Japan. If street violence or an assassination attempt were to mar the visit, Nakasone could lose favor with the Japanese public and the politicians who made him prime minister.

The Japanese governent will try to forestall violence by mobilizing thousands of police. They will impose unprecedented security that is expected to paralyze entire sections of Tokyo while Chun is in town. The Korean leader will leave his guest house to visit only two places, the prime minister's residence and the palace of Emperor Hirohito.

[UPI reported that a cache of Molotov cocktails was found yesterday on the roof of a government building in Osaka, about 250 miles west of Tokyo. Radicals opposing Chun's visit claimed responsibility for a truck bombing outside the building.]

For both sides, there is the risk the visit will heighten tensions with North Korea, which has already condemned the trip as a ruse to strengthen a "triangular" alliance between Japan, South Korea and the United States.

Chun's visit will foster the division of Korea, argues Hwang Kap Sung, president of a monthly magazine in Japan that is sympathetic to North Korea. "The dark shadow that is cast across reunification will grow even darker," he said in an interview.

The United States welcomes steps that will put two of its closest Asian allies on better terms. China, which has been developing unofficial ties with South Korea in recent months, has called the visit a step toward stability in the region.

The visit was made politically possible by Nakasone's own surprise visit to Seoul in 1983. There he expressed regret for the past and concluded a $4 billion aid package of low-interest loans for South Korea.

Few observers here expect anything of substance to be settled during Chun's return visit here. Perhaps the most satisfying immediate result for the Koreans will be a statement of apology or regret that Hirohito is expected to make.

The Koreans hope the visit will set the tone for future discussion of less easily settled issues, such as better treatment for the Korean citizens here, who are concentrated in low-income jobs.

Correction of a years-old trade deficit is another South Korean goal. The countries now have two-way trade of about $9 billion annually, with Japan ranking as South Korea's second most important trading partner. But Japan has logged a chronic trade surplus, totaling $30 billion since 1965.

The South Koreans have engineered a near miraculous economic boom from the ashes of war in the past decades. But they remain well behind their neighbor in standard of living. Given Japan's dark role in their past, South Koreans argue that they deserve special help.

Japan could help correct the deficit, they say, by providing new technology that would make Korean exports more competitive. This could be done through governmental cooperation or direct Japanese investment, which Seoul complains has slowed in recent years.

Japanese leaders, however, worry about a so-called boomerang effect. They fear Korean products produced with their technology could come back to take markets from Japan, and they have responded noncommitally. Japan has already helped Korea establish shipbuilding and steel industries, only to fight off low-priced, high-quality Korean ships and steel a few years later.

According to press reports here, the two sides will announce creation of a scientific cooperation panel and Japanese help in a technical training school during the visit. That would be a compromise, giving room for further discussion. They are also seen likely to announce a youth exchange program.

Senior South Korean military officers will accompany Chun for talks with their Japanese counterparts. The two countries have virtually no direct military relationship, although they are both allied with U.S. forces. Few observers, however, expect any significant change in military policy.