A transaction (that is not a coinbase transaction) will have specified inputs and outputs. The inputs must be comprised of valid, existing UTXOs (referenced by transaction ID and output index number, called the 'outpoint'), which will be 'consumed' to create the outputs (newly created UTXOs).
To spend any UTXO, you need to satisfy the conditions of the locking script placed on it.
I presume that its inclusion here is a reference to the Output of the originating transaction i.e. the Input of the current transaction includes a part of the Output of the previous transaction to provide extra information to the user.
If we look under the hood at how transactions work:
The transaction input will include an outpoint, as well as an unlocking script that will satisfy the scriptPubKey, and a sequence number (which is not relevant to the question at hand). The scriptPubKey for an input isn't explicitly included in the transaction data, as that would be redundant. Instead, the scriptPubKey can be looked up via the outpoint.
The outputs created by a transaction will each include a value (amount of BTC), and a scriptPubKey.
A block explorer will likely just display all of this info together for ease of use though. So if you look up a transaction ID, the scriptPubKey of the inputs may be listed, despite the fact that the actual serialized transaction data doesn't explicitly include this data (it just includes the outpoint, which is used as reference to look up the relevant data).
You can think of the outpoint as the information about which UTXO is to be spent, the scriptPubKey as the 'lock' which must be opened in order to spend it, and the scriptsig as the 'key' which will open the lock.