When and why did Wales become part of the UK?

The UK was created in 1801 between Britain and Ireland. Wales was under English rule when Britain was created in 1707.