There's a long-standing observation that countries in which stable political, economic, and technological cultures have emerged have tended to have natural defences. The British Isles and Japanese archipelago in particular both avoided successful foreign invasion or even significant attack for nearly 1,000 years, until the 20th century.
Contemporary stability has more to do with Superpower alliances than geography, though geography still matters. The grand central-European plain had been the parade ground of invading armies since before the Mongol invaders, but today is largely peaceful, so long as one looks underneath the NATO umbrella. Ukraine suffers not only flat geography, ready river and sea access, railway infrastructure, and a long and unrespected border with Russia, but status as an unalligned state, whose prior security treaties with Russia have been abrogated.
The first four factors are common to numerous other states, it's the last which has proved critical to its history since 2014.
And such alliances don't require especially robust economic capability. Among the 31 members of Nato are wealthy states in absolute (Germany) and per-capita (Liechtenstein) terms, but also some of the poorest, notably Montenegro at 75th worldwide per capita and ranked 46 of 50 among European states in overall GDP (2023). Albania, Croatia, Estonia, Iceland, Latvia, Romania, and Slovakia are other states with low overall or per-capita GDP:
State GDP EU rank GDP/capita (WW)
----- ----------- ---------------
Albania: 40 101
Belgium: 12 18
Bulgaria: 26 73
Canada: n/a n/a
Croatia: 29 54
Czechia: 19 37
Denmark: 16 9
Estonia: 35 38
Finland: 18 15
France: 3 21
Germany: 1 16
Greece: 22 39
Hungary: 24 51
Iceland: 37 6
Italy: 4 25
Latvia: 34 50
Lithuania: 30 44
Luxembourg: 27 1
Montenegro: 46 75
the Netherlands: 7 12
North Macedonia: 42 92
Norway: 13 3
Poland: 10 49
Romania: 17 55
Slovakia: 25 45
Slovenia: 31 34
Spain: 6 29
Turkey: 8 53
United Kingdom: 2 22
United States: n/a n/a
Notes:- I've listed the North American members, but omitted their GDP as these are not European states.)
- EU rank is 1--50 inclusive.
- GDP/capita rank is 1--134 within Europe, based on global IMF rankings of 192 states worldwide.
Sources:
- GDP overall: <https://en.wikipedia.org/wiki/List_of_sovereign_states_in_Eu...>
- GDP/capita: <https://en.wikipedia.org/wiki/List_of_sovereign_states_in_Eu...>
Takeaway: Alliances trump GDP or per-capita income.