c. 1300, parfitli, "completely, thoroughly, wholly;" see perfect (adj.) + -ly (2). Meaning "flawlessly, in perfect form or manner" is from late 14c.
you're perfectly right
a perfectly idiotic idea
She performed perfectly on the balance beam
solved the problem perfectly
spoke English perfectly