Given a legal chess position, is there an algorithm that gets a series of moves that lead to it? Say, given a FEN board position return a PGN move list that evaluates to it from the initial position?
The task you are considered is usually called a proof game, named such because the task is to prove that the position is legal.  As a genre of puzzles, there are various aesthetic constraints, most commonly that the resulting game be unique.  However, this is not necessary in general, and there is even a genre of counting the number of solutions.
There are several programs available that perform this task of solving proof games:

Natch is often considered the fastest.  You can see it in use in this answer to another question on this site: &quot;Can it be proven that 11. 0-0-0+ is legal in this position?&quot;

Euclide is apparently most useful when the sequence of moves is unique.

Popeye can solve many chess problems, including fairy chess problems.  Apparently it is not the most performant for proof games.

Jacobi is a program to solve (fairy) chess proof game problems.  It is written in JavaScript and run from browser, which makes it easy to try.


I have used Natch most successfully myself.