You cannot run a .NET 3.1 app on the .NET 5 runtime. A 3.1 app requires that you install the runtime for .NET 3.1 as well. Major version changes indicate a new runtime (e.g. .NET Core 2 requires the .NET Core 2.x runtime, .NET Core 3 requires the .NET Core 3.x runtime).
Note that you can write code for an app that runs on both .NET 3.1 and .NET 5 but they are compiled separately, produce separate binaries and dependencies and the appropriate version would need to be deployed onto the target machine based upon the runtime that is installed.